<template>
  <div style="width: calc(100%);background-color: #F5F7F9;box-sizing: border-box">
    <div class="login-header bg-color-white ">
      <div class="container flex-between-center height100 tw-select-none" style="font-size: 16px;color: #171920;">
        <div  class="click" @click="goHome">
          <img src="@/assets/images/common/head-logo.png" class="tw-h-55" alt="">

        </div>
        <div v-if="data.code == 'login'" style="width: 200px">
          <span>还没有账号? </span>
          <span style="color: #04ADDB;cursor: pointer" @click="goRegisterOrLogin('register')">立即注册></span>
        </div>
        <div v-if="data.code == 'register'" style="width: 200px;font-family: arial;">
          <span>已有账号 ? </span>
          <span style="color: #04ADDB;cursor: pointer" @click="goRegisterOrLogin('login')">立即登录></span>
        </div>
      </div>

    </div>
    <!--      <div class="login-container">-->
    <!--        <div style="position: absolute;right:10%;top: 12%">-->

    <!--        </div>-->
    <!--      </div>-->
    <div class="register-container flex-center ">
      <div class="flex container">
        <div class="tw-w-660 tw-h-565 tw-pt-117 flex-center">
          <img alt="" class="tw-object-cover" src="@/assets/images/user/register-bg.png"
               style="width: 454px;height:327px">
        </div>
        <LoginForm ref="loginFormRef" :code="data.code"
                   :isDialog="data.isDialog" :type="data.code"></LoginForm>
      </div>
    </div>
  </div>

  <!--    底部栏-->
  <div class=" tw-bottom-0 width100">
    <Footer/>
  </div>
</template>

<script setup>
import {getCurrentInstance, onMounted, reactive} from "vue";
import {useRoute, useRouter} from 'vue-router';
import LoginForm from './component/login-form.vue'
import Footer from "@/views/component/footer.vue";

const route = useRoute();
const router = useRouter();
const {proxy} = getCurrentInstance();

const data = reactive({
  isDialog: false,
  code: 'login',
})
onMounted(() => {
  data.code = route.query.code || 'login'
})

function goRegisterOrLogin(code) {
  let loginFormRef = proxy.$refs.loginFormRef
  data.code = code
  code == 'register'? loginFormRef.clearRegisterForm() : loginFormRef.clearLoginForm()
}

function goHome() {
  router.push({
    path: '/',
  })
}

</script>
<style lang="scss" scoped>
.login-container {
  position: absolute;
  top: 91px;
  left: 0;
  width: 100%;
  height: calc(100% - 91px);
  background-image: url('@/assets/images/user/login-bg.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;

}

.register-container {
  width: 100%;
  background-color: white;
}

.login-header {

  height: 91px;
  color: #000000;
  font-weight: 400;
  background-color: white;
  border-bottom: 1px solid #EBEBEB;
}
</style>

